# coding: utf-8
# @Author: cyl
# @File: 07链式调用.py
# @Time: 2024/07/08 20:33:28


class CallChaining:
    """链式调用"""

    def __init__(self, a, b):
        self.a = a
        self.b = b

    def add(self) -> "CallChaining":
        print("a与b相加:", self.a + self.b)
        return self

    def subtract(self) -> "CallChaining":
        print("a与b相减:", self.a - self.b)
        return self

    def multiply(self) -> "CallChaining":
        print("a与b相乘:", self.a * self.b)
        return self

    def divide(self) -> "CallChaining":
        print("a与b相除:", self.a / self.b)
        return self


if __name__ == "__main__":
    call_chain1: CallChaining = CallChaining(10, 20)
    print(
        call_chain1
        .add()
        .subtract()
        .multiply()
        .divide()
    )


"""
输出:
    a与b相加: 30
    a与b相减: -10
    a与b相乘: 200
    a与b相除: 0.5
"""

"""
场景1: 斗拱如果要实现自动化
class rectWall:
    def draw_type(self, _type: str = "wall):
        print("xxx")
        return self
    def move(self, point1: tuple):
        move(*point)
        return self
    def drag(self, point1: tuple, point2: tuple):
        drag(point1, point2)
        return self
    def clickAndInput(point1: tuple, point2: tuple, message: str);
        click(*point1)
        click(*point2)
        input(message)
        return self

rect_wall: rectWall = rectWall()
rect_wall.draw_type()
rect_wall.move((100, 200))
rect_wall.drag((100, 200), (100, 200))
recct_wall.clickAndInput((100, 200), (100, 200), "10000")

rect_wall: rectWall = rectWall()
rect_wall.move((100, 200)).drag((100, 200), (100, 200)).clickAndInput((100, 200), (100, 200), "10000")
line.draw_type("line).move((100, 200)).drag((100, 200), (100, 200)).clickAndInput((100, 200), (100, 200), "10000")


场景2: API自动化: 调用接口之后完成数据库校验+基础校验+redis校验
request_handler: RequestHandler = RequestHandler()
order模块 - function: order -> create_order(): request_handler.post("/order/create", order_id: str, order_weight: float)
order模块 - function: order -> order_object.create_order(order_id=order_id, order_weight=order_weight)
.basic_assert("stastus_code", 200)
.sql_assert(f"selct * from order where order_id = {order_id}", 1)
.redis__assert(f"selct * from order where order_id = {order_id}", 1)

test_order.py
@pytest.paramtrize(xxx)
test_order_case1(): 
    order.order(xxx)
"""
